
jQuery(document).ready(function() {
	
    /*
        Fullscreen background
    */
    $.backstretch([
		$("#PageContext").val() + "/pageAssets/login/assets/img/backgrounds/1.jpg",
		$("#PageContext").val() + "/pageAssets/login/assets/img/backgrounds/2.jpg",
		$("#PageContext").val() + "/pageAssets/login/assets/img/backgrounds/3.jpg"
	], {duration: 3000, fade: 750});
    
    /*
        Form validation
    */
    $('.login-form input[type="text"], .login-form input[type="password"], .login-form textarea').on('focus', function() {
    	$(this).removeClass('input-error');
    });
    
    $('.login-form').on('submit', function(e) {
    	
    	$(this).find('input[type="text"], input[type="password"], textarea').each(function(){
    		if( $(this).val() == "" ) {
    			e.preventDefault();
    			$(this).addClass('input-error');
    		}
    		else {
    			$(this).removeClass('input-error');
    		}
    	});
    	
    });
});

/**
 * 判断是登录账号和密码是否为空
 * @returns {boolean}
 */
function check() {
	var usercode = $("#form-username").val();
	var password = $("#form-password").val();
	if (usercode == "" || password == "") {
		$("#message").text("账号或密码不能为空！");
		return false;
	}
	return true;
}

/**
 * 跳转到注册界面
 */
function toRegister() {
	// window.open($("#PageContext").val() + "/lar/register");
	window.location = $("#PageContext").val() + "/lar/register";
}
